﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;

namespace E5_KhuyenMaiVang.Models
{
    public class MemberManager
    {
        //
        // GET: /MemberManager/

        private static GoldDealEntities dbGoldDeal = new GoldDealEntities();

        public static void AddMember(MemberView member, Guid id)
        {
            MEMBER tbMember = new MEMBER();
            tbMember.MemberID = member.MemberID;
            tbMember.MemberName = member.MemberName;
            tbMember.Birth = member.Birth;
            tbMember.Phone = member.Phone;
            tbMember.Email = member.Email;
            tbMember.CMND = member.CMND;
            tbMember.Address = member.Address;
            tbMember.Gender = member.Gender;
            tbMember.Account = id;

            dbGoldDeal.AddToMEMBER(tbMember);
            dbGoldDeal.SaveChanges();
        }

        public static MemberView ToMemberView(MEMBER m)
        {
            MemberView mv = new MemberView();
            mv.MemberName = m.MemberName;
            mv.Address = m.Address;
            mv.Phone = m.Phone;
            mv.Email = m.Email;
            mv.CMND = m.CMND;
            mv.Birth = m.Birth;
            return mv;
        }

        public static void ToMember(MEMBER m, MemberView mv)
        {            
            m.MemberName = mv.MemberName;
            m.Address = mv.Address;
            m.Phone = mv.Phone;            
            m.CMND = mv.CMND;
            m.Birth = mv.Birth;            
        }
    }
}
